﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ElingOA6_Admin_DSJCJ.Model;

namespace ElingOA6_Admin_DSJCJ.BLL
{



    public class SysPhrase
    {
        private readonly ElingOA6_Admin_DSJCJ.DAL.SysPhrase dal = new ElingOA6_Admin_DSJCJ.DAL.SysPhrase();
        public SysPhrase()
        { }



        #region  增加的方法

        /// <summary>
        ///  获得数据列表
        /// <creator>wangqy</creator>
        /// <date>2013-7-10</date>
        /// </summary>
        /// <param name="deptNo"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public List<ElingOA6_Admin_DSJCJ.Model.SysPhrase> GetPhraseManagementListByView(string strWhere)
        {
            DataSet ds = dal.GetPhraseManagementListByView(strWhere);
            return DataTableToList1(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.SysPhrase> DataTableToList1(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.SysPhrase> modelList = new List<ElingOA6_Admin_DSJCJ.Model.SysPhrase>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.SysPhrase model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ElingOA6_Admin_DSJCJ.Model.SysPhrase();
                    if (dt.Rows[n]["FPhraseID"].ToString() != "")
                    {
                        model.FPhraseID = decimal.Parse(dt.Rows[n]["FPhraseID"].ToString());
                    }
                    model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    model.FPhrase = dt.Rows[n]["FPhrase"].ToString();
                    model.FURL = dt.Rows[n]["FURL"].ToString();
                    if (dt.Rows[n]["FPubDate"].ToString() != "")
                    {
                        model.FPubDate = DateTime.Parse(dt.Rows[n]["FPubDate"].ToString());
                    }
                    model.FPubIp = dt.Rows[n]["FPubIp"].ToString();
                    model.FEmplNo = dt.Rows[n]["FEmplNo"].ToString();
                    model.FDeptNo = dt.Rows[n]["FDeptNo"].ToString();
                    model.FPhraseNo = dt.Rows[n]["FPhraseNo"].ToString();
                    if (dt.Rows[n]["FIsTop"].ToString() != "")
                    {
                        model.FIsTop = int.Parse(dt.Rows[n]["FIsTop"].ToString());
                    }

                    model.FCodeName = dt.Rows[n]["FCodeName"].ToString();
                    model.FEmpName = dt.Rows[n]["FEmpName"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="strWhere"></param>
        /// <param name="fOrderFiled"></param>
        /// <returns></returns>
        public List<ElingOA6_Admin_DSJCJ.Model.SysPhrase> GetListByPage(string tableName, string fields, int pageSize, int pageIndex, string strWhere, string fOrderFiled, int orderType, out int total)
        {
            DataSet ds = dal.GetPhraseManagementListByPage(tableName, fields, pageSize, pageIndex, strWhere, fOrderFiled, orderType, out total);
            return DataTableToList1(ds.Tables[0]);
        }

        /// <summary>
        /// 获取条数
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public int getCount(string strWhere)
        {
            return dal.getCount(strWhere);
        }


        /// <summary>
        /// 获取最新短句 部分字段 FPhrase,FURL
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public Model.SysPhrase GetModelPart(string entityNo)
        {
            return dal.GetModelPart(entityNo);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SysPhrase GetModel(decimal FPhraseID)
        {
            return dal.GetModel(FPhraseID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Model.SysPhrase model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.SysPhrase model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(decimal FPhraseID)
        {

            return dal.Delete(FPhraseID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string FEntityNo, decimal FPhraseID)
        {

            return dal.Delete(FEntityNo, FPhraseID);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string FPhraseIDlist)
        {
            return dal.DeleteList(FPhraseIDlist);
        }

        #endregion
    }
}